!     Copyright (C) 2010 Benjamin Piaud
!
!     LIMBES is free software; you can redistribute it and/or modify
!     it under the terms of the GNU General Public License as published by
!     the Free Software Foundation; either version 3, or (at your option)
!     any later version.

!     LIMBES is distributed in the hope that it will be useful,
!     but WITHOUT ANY WARRANTY; without even the implied warranty of
!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!     GNU General Public License for more details.

!     You should have received a copy of the GNU General Public License
!     along with LIMBES; if not, see <http://www.gnu.org/licenses/>


!      subroutine LIMBES_check_conserving computes the sum over the domain
!      of mass, momentum and energy


subroutine LIMBES_check_conserving(itime,time_index)
  use LIMBES_mod_var
  use LIMBES_mod_fluid_config
  implicit none
  integer*8 :: itime,i,time_index

 
  LIMBES_sum_rho(time_index)=sum(LIMBES_rho(:))
  LIMBES_sum_RT(time_index)=sum(LIMBES_RT(:))

  open(10,file=SIMUL_path(1:strlen(SIMUL_path))//'check_conserving.dat')
  do i=0,time_index
     write(10,*) i,LIMBES_sum_rho(i)/LIMBES_sum_rho(0),LIMBES_sum_RT(i)/LIMBES_sum_RT(0)
  enddo
  close(10)
end subroutine LIMBES_check_conserving
